﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Marbles.Core.Controls
{     
    [ToolboxData("<{0}:FacebookShareButton runat=server></{0}:FacebookShareButton>")]
    public class FacebookShareButton : WebControl
    {

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (!Page.ClientScript.IsClientScriptIncludeRegistered("FBSharer"))
            {
                Page.ClientScript.RegisterClientScriptInclude("FBSharer", "http://static.ak.fbcdn.net/connect.php/js/FB.Share");
            }

        }

        protected override void Render(HtmlTextWriter writer)
        {            
            writer.Write("<a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a>");
        }
    }
}

